# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=gvm-libs
pkgver=22.9.1
pkgrel=0
pkgdesc="Greenbone Vulnerability Management Libraries"
url="https://www.openvas.org/"
arch="all"
license="GPL-2.0-or-later"
options="!check" # test fails: https://github.com/greenbone/gvm-libs/issues/279
pkgusers="gvm"
pkggroups="gvm"
install="$pkgname.pre-install"
makedepends="
	bison
	cmake
	doxygen
	e2fsprogs-dev
	freeradius-client-dev
	glib-dev
	gnutls-dev
	gpgme-dev
	gpgmepp
	graphviz
	hiredis-dev
	libgcrypt-dev
	libksba-dev
	libnet-dev
	libpcap-dev
	libssh-dev
	libxml2-dev
	libxslt
	net-snmp-libs
	openldap-dev
	paho-mqtt-c-dev
	perl-sql-translator
	samurai
	util-linux-dev
	xmltoman
	"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/greenbone/gvm-libs/archive/v$pkgver.tar.gz
	glib-include-path.patch
	strptime.patch
	use-posix-addr-struct.patch
	strip-whitespace.patch
	32-bit-fix.patch
	no-werror.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_STATIC=0 \
		-DBUILD_SHARED=1 \
		-DLIBDIR=/usr/lib \
		-DSYSCONFDIR=/etc \
		-DLOCALSTATEDIR=/var

	cmake --build build --target all doc
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
	cp -a build/doc/generated/* "$pkgdir"/usr/share/doc/$pkgname

	mkdir -p "$pkgdir"/var/lib/gvm
	chown -R $pkgusers:$pkggroups "$pkgdir"/var/lib/gvm
}

sha512sums="
b06c21ced89dc9f14dd19b256b57af910f4d7e585bf9c90fb7e3c3497bb429294e3ffb64dc6ee710e8b3beeb4ca9ac6aecb9d5e4b25f0f9761fa0c9f18a8dfd1  gvm-libs-22.9.1.tar.gz
c0fe0add24cb4336f0ce313197042e60a3aba3eeb983f31b243e665a488e520ffa260ab9a3feb852500310a9df66f2eaf82ac4294d7980b983a78454b30eb9f9  glib-include-path.patch
7e98eb91143b00c35bde99e2576562c40be614f04f030b0bbc633ec987860e63771f8d61d76a5da901ac11f09a9d1fde0398eaad0ff676f3abacd2c80ef8dc69  strptime.patch
1641f2c728eecf318850446a53d6a7baf53efd33caebd1de27007a227cf48ad8d7d8ef3183d519aade2167dc9cfab3a0e33c6f37ec83b21808742f201f11e781  use-posix-addr-struct.patch
9d528ad802f0f945f96d22c5abcc3b716abd9f3f7827a745868cff5ee19dedc6ba54f9471881b2d3cd3d2d22b2e368a8280d8c49bdba0804ba86581f34f571e3  strip-whitespace.patch
33e222d9bfe05eb3c0e6a4ed706573d3c4989dc84634d4ad505a2fc7c052f5ec5919ca6613c72ef496e95046a9208a1450af47227e220ca11b93a9fb115dd6db  32-bit-fix.patch
792656e54410a2511a3e759d24ab6b48c58b69ac4a46736360ab4e75ba4bef994e7e8b7f73c421321716c9e629c480b5dd6ee47074268b6adad53131fbe632a9  no-werror.patch
"
